#include <stdio.h>
#include <stdio.h>
#include <string.h>

int main (int argc, char const* argv[])
{
    char max_name[20];
    char name[20], b_leader, b_west;
    int n, i, last_avg, class_avg, paper_cnt;
    int score, max, sum;

    scanf("%d", &n);
    max = 0;
    sum = 0;
    for (i = 0; i < n; i++) {
        score = 0;

        scanf("%s %d %d %c %c %d", name, &last_avg, &class_avg, &b_leader, &b_west, &paper_cnt);
        if (last_avg > 80 && paper_cnt > 0) score += 8000;
        if (last_avg > 85 && class_avg > 80) score += 4000;
        if (last_avg > 90) score += 2000;
        if (last_avg > 85 && b_west == 'Y') score += 1000;
        if (class_avg > 80 && b_leader == 'Y') score += 850;

        if (score > max) {
            max = score;
            strcpy(max_name, name);
        }
        sum += score;
    }

    printf("%s\n", max_name);
    printf("%d\n", max);
    printf("%d\n", sum);

    return 0;
}
